﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ScoreMS.Model;

namespace ScoreMS.BLL
{
    public class Pro_emphasisBS
    {
        static public Pro_emphasis GetPro_emphasis(string pro_emphasis_id)
        {
            using (scoremsdbEntities db = new scoremsdbEntities())
            {
                Pro_emphasis model = new Pro_emphasis();
                var pro_emphasis = db.pro_emphasis.FirstOrDefault(x => x.pro_emphasis_id == pro_emphasis_id);
                model.pro_emphasis_id = pro_emphasis.pro_emphasis_id;
                model.pro_emphasis_name = pro_emphasis.pro_emphasis_name;
                return model;
            }
        }

        /// <summary>
        /// 获取所有专业方向列表
        /// </summary>
        /// <param name="teacher_id"></param>
        /// <returns></returns>
        static public List<Pro_emphasis> GetPro_emphasisList()
        {
            using (scoremsdbEntities db = new scoremsdbEntities())
            {
                var ret = db.pro_emphasis;
                List<Pro_emphasis> list = new List<Pro_emphasis>();
                foreach (var pro_emphasis in ret)
                {
                    Pro_emphasis model = new Pro_emphasis();
                    model.pro_emphasis_id = pro_emphasis.pro_emphasis_id;
                    model.pro_emphasis_name = pro_emphasis.pro_emphasis_name;
                    list.Add(model);
                }
                return list;
            }
        }

        /// <summary>
        /// 添加专业方向
        /// </summary>
        /// <param name="student"></param>
        /// <returns></returns>
        static public bool AddPro_emphasis(Pro_emphasis model)
        {
            try
            {
                using (scoremsdbEntities db = new scoremsdbEntities())
                {
                    db.pro_emphasis.AddObject(new pro_emphasis()
                    {
                        pro_emphasis_id = model.pro_emphasis_id,
                        pro_emphasis_name = model.pro_emphasis_name,
                    });
                    db.SaveChanges();
                }
                return true;
            }
            catch
            {
                return false;
            }
        }
    }
}
